/**
 * Definition for a binary tree node.
 * function TreeNode(val, left, right) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.left = (left===undefined ? null : left)
 *     this.right = (right===undefined ? null : right)
 * }
 */
/**
 * @param {TreeNode} root
 * @return {boolean}
 */
 var isValidBST = function(root) {
    if(!root){
        return true;
    }
    let num=Number.MIN_VALUE;
    function digui(root){
        if(!root){
            return true;
        }
        let left=digui(root.left);
        if(num>root.val){
            return false;
        }
        num=root.left;
        let right=digui(root.right);
        return left && right;
    }
    return digui;
};